/**
 * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.crossriver.crgis.database.service.impl;

import java.util.List;

import com.crossriver.crgis.database.model.Application_C_of_O;
import com.crossriver.crgis.database.model.Supporting_Document;
import com.crossriver.crgis.database.service.base.Application_C_of_OLocalServiceBaseImpl;
import com.crossriver.crgis.database.service.persistence.Application_C_of_OPersistence;
import com.crossriver.crgis.database.service.persistence.Supporting_DocumentPersistence;
import com.liferay.portal.kernel.annotation.BeanReference;
import com.liferay.portal.kernel.dao.orm.DynamicQuery;
import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
import com.liferay.portal.kernel.exception.SystemException;

/**
 * The implementation of the application_ c_of_ o local service.
 *
 * <p>
 * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the {@link com.crossriver.crgis.database.service.Application_C_of_OLocalService} interface.
 * </p>
 *
 * <p>
 * Never reference this interface directly. Always use {@link com.crossriver.crgis.database.service.Application_C_of_OLocalServiceUtil} to access the application_ c_of_ o local service.
 * </p>
 *
 * <p>
 * This is a local service. Methods of this service will not have security checks based on the propagated JAAS credentials because this service can only be accessed from within the same VM.
 * </p>
 *
 * @author Wole Adetiba
 * @see com.crossriver.crgis.database.service.base.Application_C_of_OLocalServiceBaseImpl
 * @see com.crossriver.crgis.database.service.Application_C_of_OLocalServiceUtil
 */
public class Application_C_of_OLocalServiceImpl
	extends Application_C_of_OLocalServiceBaseImpl {
	
	@BeanReference(type = Application_C_of_OPersistence.class)
	protected Application_C_of_OPersistence appCofO;

	
	public List<Application_C_of_O> getApplication_C_of_OByUserId(String userId) throws SystemException {
		
		return appCofO.findByUserId(userId);
	}
	
	@SuppressWarnings("unchecked")
	public List<Application_C_of_O> getApplication_C_of_OByStatus(DynamicQuery dynamicQuery) throws SystemException {
		return (List<Application_C_of_O>) appCofO.findWithDynamicQuery(dynamicQuery);
	}
	
	
//	public List<Application_C_of_O> getApplication_C_of_OByStatusOld(String status) throws SystemException {
//		DynamicQuery query = DynamicQueryFactoryUtil.forClass(Application_C_of_O.class)
//							.add(PropertyFactoryUtil.forName("status").eq(status));
//		
//		return appCofO.findByUserId(userId);
//	}
	
	public List<Application_C_of_O> getApplication_C_of_OAll(String userId) throws SystemException {

		return appCofO.findAll();
	}
	
	
	public Application_C_of_O updateApplication_C_of_O(String appId, String status)  throws Exception{
		Application_C_of_O application = appCofO.fetchByPrimaryKey(appId);
		
		
		application.setStatus(status);
		
		appCofO.update(application, true);
		
		return application;
		
	}
}